<template>
	<el-col :span="options.span || 22" v-if="showItem">
		<el-form-item  :label="options.label" :prop="options.prop">
			<el-select style="width:100%;" :multiple="options.multiple" :filterable="options.filterable" @change="change" v-model="inputVal"
				:placeholder="options.placeholder" :clearable="options.clearable">
				<el-option v-for="(item,key) in list || vm[options.options]" :key="key"
					:label="options.labelKey? item[options.labelKey]:item.name||item.label"
					:value="options.valueKey? item[options.valueKey]:item.id||item.value" />
			</el-select>
		</el-form-item>
	</el-col>
</template>

<script>
	export default {
		props: {
			value: {
				default:'',
			},
			list: Array,
			options: Object,
		},
		inject: ['vm'],
		computed: {
			inputVal: {
				get: function() {
					return this.value;
				},
				set: function(e) {
					this.$emit("input", e);
				},
			},
			showItem() {
				if (this.options.show) return this.options.show(this.vm)
				return true;
			}
		},
		methods: {
			change(e) {
				if (this.options.change) {
					this.vm[this.options.change](e);
				}
			}
		}
	};
</script>

<style>
</style>